import { useRoutes, Navigate, RouteObject, createBrowserRouter } from "react-router-dom";
import { lazy, Suspense } from "react";
const App = lazy(()=> import("../App.tsx"));
const HomePage = lazy(()=> import("../views/HomePage/index.tsx"));
const OnePage = lazy(()=> import("../views/OnePage/Index.tsx"));

export const routes: Array<object> = [
  {
    path: "/",
    element: <App/>,
    children:[
      {
        path: "/",
        element: <Navigate to="/HomePage" replace />
      },
      {
        path: "/HomePage",
        element: ( 
          <Suspense fallback={<div>Loading...</div>}>
            <HomePage/>
          </Suspense> 
        )
      },
      {
        path: "/OnePage",
        element: ( 
          <Suspense fallback={<div>Loading...</div>}>
            <OnePage/>
          </Suspense> 
        )
      },
    ]
  },
]


const router = createBrowserRouter(routes);


export default router;